App({
    globalData: {
      url: '', //头像
      openid: null,
      nicheng: '', //昵称
      switch: '',
      index:0
    },
    onLaunch: async function () {
      var that = this
      wx.cloud.init({
        //env:使用的云开发环境,默认第一个
        env: 'duasss-8go24puka422939f',
        traceUser: true,
      })
      await wx.cloud.callFunction({
        name: "getopenid",
        success: function (e) {
          that.globalData.openid = e.result.openid
          wx.cloud.database().collection("user").where({
            _openid: e.result.openid
          }).get({
            success: function (e) {
              if (e.data.length != 0) {
                that.globalData.nicheng = e.data[0].nickName
                that.globalData.url = e.data[0].avatarUrl
              }
            }
          });
        }
      });
      const db = wx.cloud.database({ // 链接数据表
        env: "duasss-8go24puka422939f"
      });
       db.collection('switch').where({}).get({
        success: function (res) {
          that.globalData.switch = res.data[0].switch
          that.globalData.switch1=res.data[1].switch
        }
      })
    }
  })